package com.springboot.onlinemusicserver.controller;

import com.springboot.onlinemusicserver.model.Music;
import com.springboot.onlinemusicserver.model.MusicLove;
import com.springboot.onlinemusicserver.service.MusicLoveService;
import com.springboot.onlinemusicserver.utils.common.Result;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletRequest;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * Description :
 * User: jiume
 * Date: 2025-05-25
 * Time: 19:56
 */
@RestController
@RequestMapping("/musicLove")
public class MusicLoveController {

    @Resource
    private MusicLoveService musicLoveService;

    // 收藏音乐
    @PostMapping("/collect")
    public Result<Boolean> collectMusicLove(Long musicId, HttpServletRequest request) {
        return musicLoveService.collectMusicLove(musicId, request);
    }

    // 取消收藏
    @PutMapping("/cancel")
    public Result<Boolean> cancelMusicLove(Long musicId, HttpServletRequest request) {
        return musicLoveService.cancelMusicLove(musicId, request);
    }

    @GetMapping("/findMusicLove")
    public Result<List<Music>> selectMusicLoveList(String selectName, HttpServletRequest request) {
        return musicLoveService.selectMusicLoveList(selectName, request);
    }
}
